/**
 * @file asteroid.h
 * @brief  spawn, move, update and init struct_enemy
 */

/**
 * @def ASTEROID_H
 */

#include <allegro5/allegro5.h>

#ifndef ASTEROID_H
#define ASTEROID_H
#define ASTEROIDS_MAX 15
#define ASTEROID_SCALE_MIN 0.5f
#define ASTEROID_TWIST_MAX 10.0f
#define ASTEROID_HEADING_MAX 10.0f
/**
 * @struct struct_enemy
 * @brief structure to define general enemy with basic parameters.
 * @param sx - x coordinate on the plane
 * @param sy - y coordinate on the plane
 * @param heading - velocity vector of the enemy(in radians)
 * @param twist - how the "sprite" is rotated
 * @param rot_velocity - how fast is "sprite" rotates
 * @param scale - how big is the enemy
 * @param gone - is it dead
 * @param color - ALLEGRO_COLOR structure
 * */
typedef struct struct_enemy {
  float sx;
  float sy;
  float heading;
  float twist;
  float speed;
  float rot_velocity;
  float scale;
  int gone;
  ALLEGRO_COLOR color;
} Asteroid;

/**
 * @fn void asteroid_init(Asteroid *a) - allocating memory for asteroid and initalizing it's starting values
 * all randomization was taken from https://c-faq.com/lib/randrange.html
 * @param a - pointer, the memory will be allocated into it
 */
void asteroid_init(Asteroid *a);
/**
 * @fn void asteroid_check_pos(Asteroid *a); - checks is asteroid is out of bounds
 * @param a - pointer to Asteroid
 */
void asteroid_check_pos(Asteroid *a);
/**
 * @fn void asteroid_move(Asteroid *a, void (*direction)(float *sx, float *sy, float speed, float heading))
 * moves the asteroid with it's init speed in the direction of heading
 * @param a - pointer to asteroid to move
 * @param direction - pointer to the movement.h functions
 */
void asteroid_move(Asteroid *a,
    void (*direction)(float *sx, float *sy, float speed, float heading));
/**
 * @fn void asteroids_init(Asteroid **as) - initializes array of asteroids size of ASTEROIDS_MAX
 * @param as - array to be filled with asteroids. It allocates memory using asteroid
 */
void asteroids_init(Asteroid **as);
/**
 * @fn void asteroids_update(Asteroid **as) - calles asteroid_update for every asteroid in as array
 * @param as - array of Asteroid to be updated.
 */
void asteroids_update(Asteroid **as);
/**
 * @fn void asteroids_free(Asteroid **as) - frees memory of every asteroid in array as
 * @param as - array of Asteroid to free.
 */
void asteroids_free(Asteroid **as);
#endif
